﻿@using System.Globalization
@using Abp.Json
@using Magicodes.Admin.MultiTenancy
@using Magicodes.Admin.MultiTenancy.Payments
@using Magicodes.Admin.Web.Models.TenantRegistration
@addTagHelper *, PaulMiami.AspNetCore.Mvc.Recaptcha
@{
    Layout = "~/Views/Account/_Layout.cshtml";
    ViewBag.DisableTenantChange = true;
}
@model TenantRegisterViewModel
@section Scripts
{
    <script>
        window.passwordComplexitySetting = @Html.Raw(Model.PasswordComplexitySetting.ToJsonString(indented: true));
    </script>
    <environment names="Development">
        <script src="~/view-resources/Views/TenantRegistration/Register.js" asp-append-version="true"></script>
    </environment>

    <environment names="Staging,Production">
        <script src="~/view-resources/Views/TenantRegistration/Register.min.js" asp-append-version="true"></script>
    </environment>

    <recaptcha-script />
}

<form class="register-form" asp-action="Register" method="post" id="formTenantRegister">
    <input type="hidden" Name="EditionId" value="@Model.EditionId" />
    @if (Model.EditionId.HasValue)
    {
        <input type="hidden" Name="SubscriptionStartType" value="@Model.SubscriptionStartType" />
        <input type="hidden" name="EditionPaymentType" value="@Model.EditionPaymentType" />
        <input type="hidden" name="Gateway" value="@Model.Gateway" />
        <input type="hidden" name="PaymentId" value="@Model.PaymentId" />
    }

    <h3>@L("TenantSignUp")</h3>
    @if (Model.EditionId.HasValue)
    {
        <div class="hint text-center">(@L("Edition"): @Model.Edition.DisplayName)</div>
    }

    @if (@ViewBag.ErrorMessage != null)
    {
        <div class="alert alert-danger">
            <i class="fa fa-warning"></i> @ViewBag.ErrorMessage
        </div>
    }

    <p class="hint">
        @L("TenantInformations")
    </p>
    <div class="form-group">
        <label class="control-label visible-ie8 visible-ie9">@L("TenancyName")</label>
        <input class="form-control placeholder-no-fix input-ltr" type="text" placeholder="@L("TenancyName")" name="TenancyName" required maxlength="@Tenant.MaxTenancyNameLength" />
    </div>
    <div class="form-group">
        <label class="control-label visible-ie8 visible-ie9">@L("Name")</label>
        <input class="form-control placeholder-no-fix" type="text" placeholder="@L("Name")" name="Name" required maxlength="@Magicodes.Admin.Authorization.Users.User.MaxNameLength" />
    </div>
    <p class="hint">
        @L("AccountSettings")
    </p>
    <div class="form-group">
        <label class="control-label visible-ie8 visible-ie9">@L("AdminEmailAddress")</label>
        <input class="form-control placeholder-no-fix" type="email" placeholder="@L("AdminEmailAddress")" name="AdminEmailAddress" required maxlength="@Magicodes.Admin.Authorization.Users.User.MaxEmailAddressLength" />
    </div>
    <div class="form-group">
        <label class="control-label visible-ie8 visible-ie9">@L("AdminPassword")</label>
        <input class="form-control placeholder-no-fix" type="password" autocomplete="off" id="AdminPassword" placeholder="@L("AdminPassword")" name="AdminPassword" required />
    </div>
    <div class="form-group">
        <label class="control-label visible-ie8 visible-ie9">@L("AdminPasswordRepeat")</label>
        <input class="form-control placeholder-no-fix" type="password" autocomplete="off" placeholder="@L("AdminPasswordRepeat")" name="AdminPasswordRepeat" required />
    </div>

    @if (ViewBag.UseCaptcha)
    {
        <p class="hint">
            @L("Captha_Hint")
        </p>
        <div class="form-group margin-bottom-20">
            <recaptcha />
        </div>
    }

    <div class="form-actions">
        <a asp-action="SelectEdition" asp-controller="TenantRegistration">
            <button type="button" id="register-back-btn" class="btn btn-default">@L("Back")</button>
        </a>
        <button type="submit" id="register-submit-btn" class="btn btn-success uppercase pull-right">@L("Submit")</button>
    </div>
</form>